package com.o2opuzi.lib.db;

import javax.servlet.ServletContext;
import javax.sql.DataSource;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.context.ServletContextAware;

/**
 * @author yue han jiang
 * @date 2015年1月9日
 * @file_name DbHelper.java
 */
@SuppressWarnings("static-access")
public class DbHelper extends JdbcTemplate{
	
	private static DataSource dataSource;

	public DbHelper(){
		if(dataSource != null){
			super.setDataSource(dataSource);
		}
	}
	
	public DbHelper(DataSource dataSource){
		super(dataSource);
	}
	
	@Override
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
		super.setDataSource(this.dataSource);
	}
	
	@Override
	public DataSource getDataSource() {
		return this.dataSource;
	}
	
	public static  DbHelper db(){
		return new DbHelper();
	}
}
